package cn.demomaster.quickpicturer.config;

import android.app.Activity;
import android.net.Uri;

import androidx.fragment.app.Fragment;

import java.io.File;

import cn.demomaster.quickpicturer.constants.ImageSourceType;

public class ImageConfig {

    private ImageSourceType[] sources;
    private String[] sourceNames;
    public Uri outputUri = null;//输出文件存放位置
    public Uri outCropUri = null;//输出文件存放位置
    public String outputPath = null;//输出文件存放位置
    private int maxImages = 1;
    private boolean multipleSelection;
    private int cropWidth;
    private int cropHeight;
    File saveDirectory;
    String authority;//FileProvider

     Activity activity;
     Fragment fragment;
    // Constructors, getters, and setters

    public ImageConfig(ImageConfigBuilder builder) {
        this.sources = builder.getSources();
        this.maxImages = builder.getMaxImages();
        this.cropHeight = builder.getCropHeight();
        this.cropWidth = builder.getCropWidth();
        this.sourceNames = builder.getSourceNames();
        this.activity = builder.activity;
        this.fragment = builder.fragment;
        this.saveDirectory = builder.saveDirectory;
        this.authority = builder.authority;
    }

    public ImageConfig setCropWidth(int cropWidth) {
        this.cropWidth = cropWidth;
        return this;
    }

    public ImageConfig setCropHeight(int cropHeight) {
        this.cropHeight = cropHeight;
        return this;
    }

    public ImageConfig setSaveDirectory(File saveDirectory) {
        this.saveDirectory = saveDirectory;
        return this;
    }

    public ImageSourceType[] getSources() {
        return sources;
    }

    public void setSources(ImageSourceType[] sources) {
        this.sources = sources;
    }

    public int getMaxImages() {
        return maxImages;
    }

    public void setMaxImages(int maxImages) {
        this.maxImages = maxImages;
    }

    public boolean isMultipleSelection() {
        return multipleSelection;
    }

    public void setMultipleSelection(boolean multipleSelection) {
        this.multipleSelection = multipleSelection;
    }

    public String[] getSourceNames() {
        return sourceNames;
    }

    public int getCropWidth() {
        return cropWidth;
    }

    public int getCropHeight() {
        return cropHeight;
    }

    public File getSaveDirectory() {
        return saveDirectory;
    }

    public Uri getOutputUri() {
        return outputUri;
    }

    public void setOutputUri(Uri outputUri) {
        this.outputUri = outputUri;
    }

    public String getOutputPath() {
        return outputPath;
    }

    public void setOutputPath(String outputPath) {
        this.outputPath = outputPath;
    }

    public void setOutCropUri(Uri outCropUri) {
        this.outCropUri = outCropUri;
    }

    public void setAuthority(String authority) {
        this.authority = authority;
    }

    public Activity getActivity() {
        if(fragment != null){
            return fragment.getActivity();
        }
        return activity;
    }

    public void setActivity(Activity activity) {
        this.activity = activity;
    }

    public Fragment getFragment() {
        return fragment;
    }

    public void setFragment(Fragment fragment) {
        this.fragment = fragment;
    }
}
